package com.fish.admin.module.auth.controller;

import com.fish.admin.module.auth.domain.dto.AuthInfoPageQueryDTO;
import com.fish.admin.module.auth.domain.vo.AuthInfoVO;
import com.fish.admin.module.auth.service.AuthInfoService;
import com.fish.common.core.domain.vo.PageVO;
import com.fish.common.core.enums.EnabledEnum;
import com.fish.common.core.response.RestResponse;
import com.fish.common.support.util.EnumUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/auth/info")
@RequiredArgsConstructor
public class AuthInfoController {


    private final AuthInfoService authInfoService;
    /**
     * 页获取认证账号
     * @param authInfoPageQuery
     * @return
     */
    @PostMapping("/v1/page")
    public RestResponse<PageVO<AuthInfoVO>> page(
            @RequestBody AuthInfoPageQueryDTO authInfoPageQuery) {
        return RestResponse.ok(authInfoService.page(authInfoPageQuery));
    }

    @PostMapping("/v1/changeEnabled/{id}/{enabled}")
    public RestResponse changeEnabled(@PathVariable Long id, @PathVariable Integer enabled) {
        authInfoService.changeEnabled(id, EnumUtils.getEnum(enabled, EnabledEnum.class));
        return RestResponse.ok();
    }


}
